<?php
/**
 * This file is part of the Anota project.
 * 2011-2012 Fernando Garcia Huerta <fgarciahue@uoc.edu>
 * 
 * UOC - FUNDAMENTOS DE INFORMÁTICA EN ENTORNOS BIOINFORMÁTICOS - PEC2
 */

/**
 * DboProc
 * 
 * Represents a row in procs table
 * 
 * @package    Anota
 * @subpackage database
 * @author     Fernando Garcia Huerta <fgarciahue@uoc.edu>
 */
class DboProc extends DboBase {

    public
    $id = null,             // id field
    $ip = null,             // ip field
    $filesize = null,       // filesize field
    $options = null,        // options field
    $created_at = null,     // created_at field
    $updated_at = null;     // updated_at field

    /**
     * Constructor.
     * 
     * Fix name of the table
     */
    public function __construct() {
        self::$TABLE = 'procs';
    }
    
    /**
     * Sets id field value
     * 
     * @param int $id 
     */
    protected function setId($id) {
        $this->id = $id;
    }
    
    /**
     * Returns insert query
     * 
     * @return string insert query
     */
    protected function getInsertQuery() {
        $query = sprintf("INSERT INTO %s VALUES(NULL, '%s', '%s', '%s', NOW(), NOW())",
            DboProc::$TABLE, $this->ip, $this->filesize, $this->options);
        return $query;
    }

    /**
     * Return update query
     * 
     * @return string update query
     */
    protected function getUpdateQuery() {
        $query = sprintf("UPDATE %s SET updated_at=NOW() WHERE id='%s'", 
            DboProc::$TABLE, $this->id);
        return $query;
    }
    
}